from __future__ import unicode_literals


from django.contrib.auth.models import User
from django.db import models
from django.core.urlresolvers import reverse
from multiselectfield import MultiSelectField
import datetime





class Record(models.Model):


    Light_sensitivity = 'Light_sensitivity'
    Headache = 'Headache'
    Dizziness = 'Dizziness'
    Blurry_vision = 'Blurry_vision'
    Increased_difficulty_concentrating = "Increased_difficulty_concentrating"
    Others = 'Others'

    Reading ='reading for leisure (specify book, magazine, newspaper)'
    Computer = 'computer Work (browsing internet, research)'
    Phone = 'use of tablet or smart phone'
    Studying = 'studying'
    Paying_bills = 'paying bills'
    Eating = 'eating in a restaurant'
    Talking = 'taking public transportation'
    Movies = 'going to the movies or theater'
    Sport = 'attending a sporting event'
    Religious = 'attending religious service'
    Work = 'work related task (please specify)'
    Exercise = 'physical exertion or exercise'
    Laundry = 'laundry'
    Cleaning = 'cleaning'
    Cooking = 'cooking'

    Mile = "Mile"
    Moderate = "Moderate"
    Severe = "Severe"



    symptoms_to_choose = (
        (Light_sensitivity, 'light sensitivity'),
        (Headache, 'headache'),
        (Dizziness, 'dizziness'),
        (Blurry_vision, 'blurry vision'),
        (Increased_difficulty_concentrating,'increased difficulty concentrating'),
        (Others,'others')
    )



    degrees = (
        (Mile,'mild'),
        (Moderate,'moderate'),
        (Severe,'severe')
    )


    activity_to_choose =(
        (Reading,'reading for leisure (specify book, magazine, newspaper)'),
        (Computer,'computer Work (browsing internet, research)'),
        (Phone,'use of tablet or smart phone'),
        (Studying, 'studying'),
        (Paying_bills, 'paying bills'),
        (Eating, 'eating in a restaurant'),
        (Talking, 'taking public transportation'),
        (Movies, 'going to the movies or theater'),
        (Sport, 'attending a sporting event'),
        (Religious,'attending religious service'),
        (Work, 'work related task (please specify)'),
        (Exercise, 'physical exertion or exercise'),
        (Laundry, 'laundry'),
        (Cleaning, 'cleaning'),
        (Cooking, 'cooking'),
        (Others, 'others'),
    )

    patient = models.ForeignKey(User, on_delete=models.CASCADE)
    flare_up_time = models.DateTimeField(("flare up time"), default=datetime.datetime.now)
    symptoms = models.CharField(
        max_length=250,
        choices=symptoms_to_choose,
        blank=False
    )

    symptoms_level = models.CharField(
        max_length=20,
        choices=degrees,
        blank=False
    )

    activity_performed_during_onset_of_symptoms = models.CharField(
        max_length=500,
        choices=activity_to_choose,
        blank=False
    )

    symptoms2 = models.CharField(
        max_length=250,
        choices=symptoms_to_choose,
        blank=True
    )

    symptoms_level2 = models.CharField(
        max_length=20,
        choices=degrees,
        blank=True
    )

    activity_performed_during_onset_of_symptoms2 = models.CharField(
        max_length=500,
        choices=activity_to_choose,
        blank=True
    )

    symptoms3 = models.CharField(
        max_length=250,
        choices=symptoms_to_choose,
        blank=True
    )

    symptoms_level3 = models.CharField(
        max_length=20,
        choices=degrees,
        blank=True
    )

    activity_performed_during_onset_of_symptoms3 = models.CharField(
        max_length=500,
        choices=activity_to_choose,
        blank=True
    )
    optional_description = models.CharField(max_length=500,blank=True)
    update = models.DateTimeField(auto_now=True, auto_now_add=False)
    timestamp = models.DateTimeField(auto_now=False, auto_now_add=True)



    def __unicode__(self):
        return self.patient.username

    def __str__(self):
        return self.patient

    def get_absolute_url(self):
       return reverse("posts:details",kwargs={"id":self.id})
       # return "posts/details/%s" %(self.id)

    def get_absolute_url1(self):
       return reverse("posts:update",kwargs={"id":self.id})

    def get_absolute_url2(self):
       return reverse("posts:delete",kwargs={"id":self.id})

